package phapp.service.barapp.impl;

import static javacommon.util.Struts2JsonHelper.outJson;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import cn.org.rapid_framework.page.Page;
import cn.org.rapid_framework.page.PageRequest;
import javacommon.base.*;

import phapp.model.barapp.*;
import phapp.dao.barapp.*;
import phapp.service.barapp.impl.*;
import phapp.service.barapp.*;
/**
 * <p> 标题: 酒吧在线会员状态表, tc_bar_online_info  业务处理层
 * <p>Description: spring事务实现层,调用Dao层取数据
 * <p>Copyright: Copyright (c) 2014-10
 * <p>Company: 
 * @see phapp.model.barapp.BarOnline
 * @see phapp.service.barapp.BarOnlineManager
 * @see phapp.dao.barapp.BarOnlineDao
 * @author you name
 * @version 1.0
*/

@Component("barOnlineManager")
@Transactional
public class BarOnlineManagerImpl extends BaseManager<BarOnline,java.lang.Integer>
               implements BarOnlineManager {

   /**定义Dao*/
   private BarOnlineDao barOnlineDao;
   /**增加setXXXX()方法,spring就可以通过autowire自动设置对象属性*/
   public void setBarOnlineDao(BarOnlineDao dao) {
      this.barOnlineDao = dao;
   }

   /**获取Dao*/
   public EntityDao getEntityDao() {
      return this.barOnlineDao;
   }

   /**
   * <p>分页查询BarOnline<br>
   * @param PageRequest pr
   * @return Page
   * @author
   */
   @Transactional(readOnly=true)
   public Page findByPageRequest(PageRequest pr) {
      return barOnlineDao.findByPageRequest(pr);
   }

   /**
   * <p>批量删除 BarOnline<br>
   * @param BarOnline u
   * @return Boolean
   * @author
   */
   public Boolean  removeByIdArry(BarOnline u) {
      Boolean result =false;
      int i =-1,size=u.getIdList().size();
      i =barOnlineDao.removeByIdArry(u);
      if(i==size){
         result =true;
      }else{
         throw new RuntimeException();
      }
      return result;
   }
	/**
	* <p> Bean查询 <br> 
	* @param BarOnline bean
	* @return  BarOnline
	* @author
	*/

	/**
	* <p>按Bean查询返回List<br> 
	* @param BarOnline bean
	* @return List
	* @author
	*/
	public java.util.List  findListByBean(BarOnline u) { 
		java.util.List<BarOnline> list =  barOnlineDao.findListByBean(u); 
	      return list;
	}
    /**
     * <p>标题: 查询 酒吧在线会员,返回列表
     * <p>参数: Map 
     * <p>Map 说明: String barId  酒吧 Id String sex 性别:1男,2女 ,String control 1:查好友,2:取非好友
     */
    public List  getBarOnlineList(java.util.Map map) {
    	java.util.List<BarOnline> list =  barOnlineDao.getBarOnlineList(map); 
	    return list;
    }
    /**
     * <p>标题: 修改我的在线信息(酒吧、台桌)
     * <p>参数: String barId  酒吧Id ,String menberId 会员ID , String  deskId 吧台ID(吧台名)
     * @see phapp.model.barapp.BarOnline
     */
    public void  updateMeOnline(String barId ,String menberId, String  deskId) {
    	BarOnline paramOneline = new BarOnline(); 
    	if(javacommon.util.StringTool.isNumeric(menberId)){
    		paramOneline.setMenberId(Integer.parseInt(menberId)); 
    		int count = removeByBean(paramOneline);
    	}
    	if(javacommon.util.StringTool.isNumeric(barId)){
    		paramOneline.setBarId(Integer.parseInt(barId));
    	}
    	if(javacommon.util.StringTool.isNumeric(deskId)){
    		paramOneline.setDeskId(Integer.parseInt(deskId));
    	}
    	paramOneline.setDeskName(deskId);
    	save(paramOneline);
    }
    /**
     * <p> 标题:按对象批量删除<br>
     * <p>Description :
     * @param BarOnline u
     * @return int
     */
     public int removeByBean(BarOnline u) {
        int i=-1;
        i =barOnlineDao.removeByBean(u);
        return i;
     }  
 	/**
 	 * <p>通过 Map 修改一条 数据<br> 
 	 * @param  java.util.Map 
 	*/
    public int updateByMap(java.util.Map map){
    		int count = barOnlineDao.updateByMap(map);
    		return count;
    }
    
}
